package com.ruoyi.basebill.controller;

import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.basebill.domain.WfzJtgzflentry;
import com.ruoyi.basebill.domain.WfzSbsjsentry;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.basebill.domain.WfzJtgzfl;
import com.ruoyi.basebill.service.IWfzJtgzflService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 薪酬总-计提工资福利Controller
 *
 * @author wyx
 * @date 2022-12-21
 */
@RestController
@RequestMapping("/basebill/jtgzfl")
public class WfzJtgzflController extends BaseController
{
    @Autowired
    private IWfzJtgzflService wfzJtgzflService;

    /**
     * 查询薪酬总-计提工资福利列表
     */
    @PreAuthorize("@ss.hasPermi('basebill:jtgzfl:list')")
    @GetMapping("/list")
    public TableDataInfo list(WfzJtgzfl wfzJtgzfl)
    {
        startPage();
        List<WfzJtgzfl> list = wfzJtgzflService.selectWfzJtgzflList(wfzJtgzfl);
        return getDataTable(list);
    }

    /**
     * 导出薪酬总-计提工资福利列表
     */
    @PreAuthorize("@ss.hasPermi('basebill:jtgzfl:export')")
    @Log(title = "薪酬总-计提工资福利", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WfzJtgzfl wfzJtgzfl)
    {
        List<WfzJtgzfl> list = wfzJtgzflService.selectWfzJtgzflList(wfzJtgzfl);
        ExcelUtil<WfzJtgzfl> util = new ExcelUtil<WfzJtgzfl>(WfzJtgzfl.class);
        util.exportExcel(response, list, "薪酬总-计提工资福利数据");
    }

    /**
     * 下载模板
     * @param response
     */
    @PostMapping("/importTemplate")
    public void importTemplate(HttpServletResponse response)
    {
        ExcelUtil<WfzJtgzflentry> util = new ExcelUtil<>(WfzJtgzflentry.class);
        util.importTemplateExcel(response,"案卷数据");
    }

    /**
     * 获取薪酬总-计提工资福利详细信息
     */
    @PreAuthorize("@ss.hasPermi('basebill:jtgzfl:query')")
    @GetMapping(value = "/{fid}")
    public AjaxResult getInfo(@PathVariable("fid") Long fid)
    {
        return success(wfzJtgzflService.selectWfzJtgzflByFid(fid));
    }

    /**
     * 新增薪酬总-计提工资福利
     */
    @PreAuthorize("@ss.hasPermi('basebill:jtgzfl:add')")
    @Log(title = "薪酬总-计提工资福利", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WfzJtgzfl wfzJtgzfl)
    {
        wfzJtgzfl.setFcreator(getUsername());
        wfzJtgzfl.setFlastupdateuser(getUsername());

        wfzJtgzfl.setFstate("SAVE");
        wfzJtgzfl.setFcreatetime(new Date());
        wfzJtgzfl.setFlastupdatetime(new Date());
        return toAjax(wfzJtgzflService.insertWfzJtgzfl(wfzJtgzfl));
    }

    /**
     * 修改薪酬总-计提工资福利
     */
    @PreAuthorize("@ss.hasPermi('basebill:jtgzfl:edit')")
    @Log(title = "薪酬总-计提工资福利", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WfzJtgzfl wfzJtgzfl)
    {

        wfzJtgzfl.setFlastupdateuser(getUsername());
        wfzJtgzfl.setFlastupdatetime(new Date());
        return toAjax(wfzJtgzflService.updateWfzJtgzfl(wfzJtgzfl));
    }

    /**
     * 删除薪酬总-计提工资福利
     */
    @PreAuthorize("@ss.hasPermi('basebill:jtgzfl:remove')")
    @Log(title = "薪酬总-计提工资福利", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fids}")
    public AjaxResult remove(@PathVariable Long[] fids)
    {
        return toAjax(wfzJtgzflService.deleteWfzJtgzflByFids(fids));
    }

    /**
     * 审核薪酬总表—计提工资福利
     */

    @Log(title = "薪酬总-计提工资福利", businessType = BusinessType.UPDATE)
    @PutMapping("/operation/{fids}/{fstate}")
    public AjaxResult operation(@PathVariable Long[] fids,@PathVariable String fstate) {

        return  toAjax(wfzJtgzflService.operation(fids,fstate));
    }
}
